<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <h1>hello</h1>

  <script>
    
    // var ws = new WebSocket("wss://127.0.0.1:9999");

    // ws.onopen = function(evt) { 
    //   console.log("Connection open ..."); 
    //   ws.send("Hello WebSockets!");
    // };

    // ws.onmessage = function(evt) {
    //   console.log( "Received Message: " + evt.data);
    //   ws.close();
    // };

    // ws.onclose = function(evt) {
    //   console.log("Connection closed.");
    // };

    // switch (ws.readyState) {
    //   case 0:
    //     // do something
    //     break;
    //   case 1:
    //     // do something
    //     break;
    //   case 2:
    //     // do something
    //     break;
    //   case 3:
    //     // do something
    //     break;
    //   default:
    //     // this never happens
    //     break;
    // }

    var ws = new WebSocket('ws://localhost:8888');
  ws.onopen = function () {
    console.log('ws onopen');
    ws.send('from client: hello');
  };
  ws.onmessage = function (e) {
    console.log('ws onmessage');
    console.log('from server: ' + e.data);
  };

  </script>
</body>
</html>